import shelve

article_db = shelve.open('stock_articles.she')

no_of_articles = 0
for stock in article_db:
    print 'Counting articles...'
    no_of_articles += len(article_db[stock])

print '%d articles in total' % no_of_articles
